package com.wzx.service.impl;

import com.wzx.dao.IPersonDao;
import com.wzx.domain.Person;
import com.wzx.service.IPersonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class PersonServiceImpl implements IPersonService {
    @Autowired
    private IPersonDao iPersonDao;
    @Override
    public List<Person> findAll() {
        List<Person> list = iPersonDao.findAll();
        return list;
    }

    @Override
    public void savePerson(Person person) {
        iPersonDao.save(person);
    }

    @Override
    public void savePersons(List<Person> persons) {
        for (int i = 0; i < persons.size(); i++) {
//            if(i==2){
//                System.out.println(1/0);
//            }
            iPersonDao.save(persons.get(i));
        }
    }
}
